package c.e.b.n;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Build.VERSION;
import android.os.Bundle;
import c.e.b.j.c;
import com.huawei.hms.analytics.core.crypto.AesCipher.AesLen;

/* compiled from: DataCollectionConfigStorage */
public class a {
    public final Context a;
    public final SharedPreferences b;
    public final c c;
    public boolean d;

    public a(Context context, String str, c cVar) {
        boolean z;
        int i = VERSION.SDK_INT;
        if (i >= 24) {
            Object obj = b.i.c.a.a;
            context = i >= 24 ? context.createDeviceProtectedStorageContext() : null;
        }
        this.a = context;
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("com.google.firebase.common.prefs:");
        stringBuilder.append(str);
        SharedPreferences sharedPreferences = context.getSharedPreferences(stringBuilder.toString(), 0);
        this.b = sharedPreferences;
        this.c = cVar;
        String str2 = "firebase_data_collection_default_enabled";
        boolean z2 = true;
        if (sharedPreferences.contains(str2)) {
            z = sharedPreferences.getBoolean(str2, true);
        } else {
            try {
                PackageManager packageManager = context.getPackageManager();
                if (packageManager != null) {
                    ApplicationInfo applicationInfo = packageManager.getApplicationInfo(context.getPackageName(), AesLen.ROOTKEY_COMPONET_LEN);
                    if (applicationInfo != null) {
                        Bundle bundle = applicationInfo.metaData;
                        if (bundle != null && bundle.containsKey(str2)) {
                            z2 = applicationInfo.metaData.getBoolean(str2);
                        }
                    }
                }
            } catch (NameNotFoundException unused) {
            }
            z = z2;
        }
        this.d = z;
    }
}
